/**
 * The ajax-select JavaScript template.
 */

// Wait until browser DOM is loaded
document.observe("dom:loaded", function() {

    // Observe the selected element's "change" event, which triggers the given function.
    // Note that $selector is a Velocity variable passed in from the AjaxSelect.java Page
    $('$selector').observe('change', function(event){

        // Retrieve the source of the event, in this case the Select control
        var select = Event.element(event);

        // $target, $context and $path are Velocity variables that are passed in
        // from the AjaxSelect.java Page
        new Ajax.Updater('$target', '$context$path', {
            method: 'get',
            parameters: {'pageAction' : 'onClickUser', 'userId' : select.value}
        });
    });
});
